package org.go.test;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;

import org.go.util.XmlUtil;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;

public class xml {
	@Test
	public void doWork() throws Exception {
		String str = "c:/web.xml";
		File propFile = new File(str);
		if (propFile.exists()) {
			InputStream in = new BufferedInputStream(new FileInputStream(str));
			Document doc = XmlUtil.processFile(in, "1");
			System.out.println(doc.toString());
		}
	}

	@Test
	public void main() {
		new Dom().readXML("c:/web.xml");
	}

	@Test
	public void main1() throws Exception {
		String str = "c:/web.xml";
		InputStream in = new BufferedInputStream(new FileInputStream(str));
		new Dom().readXML(in);
	}

	@Test
	public void main2() throws Exception {
		String str = "c:/go.xml";
		InputStream in = new BufferedInputStream(new FileInputStream(str));
		Document document = XmlUtil.readXML(in);
		XPath xpath = XmlUtil.buildXpath();
		NodeList deleteJobNodes = (NodeList) xpath.evaluate("/go/threadpools/threadpool", document, XPathConstants.NODESET);
		XmlUtil.loopNode(deleteJobNodes);
		//new Dom().readXML(in);
	}
}
